/*
 * MyProcess.h
 *
 *  Created on: 14/07/2009
 *      Author: banouz
 */

#ifndef MYPROCESS_H_
#define MYPROCESS_H_


#include <iostream>
#include <stdio.h>
#include <stdlib.h>
#include <errno.h>
#include <string.h>
#include <vector>

using namespace std;

class UI;
class MyProcess

{

private:

  UI* _ui;
  int _pFdTable [12];
  int _size;
  int _id;
  string _workingDirectory;
  int _parent;
  pthread_t   m_thread;
  vector<string>* _commands;
  pthread_cond_t  m_qCond;
  pthread_mutex_t m_mutex;

public:
  MyProcess(UI* u,int id,int pId);
  virtual ~MyProcess();

  void start(void* a);
  void *startUi();
  void wakeup();

  int setFD(int index,int fdNum);

    int* getFdTable()
    {
        return _pFdTable;
    }

    pthread_mutex_t* getMutex() //Eran
    {
        return &m_mutex;
    }

    void setMutex(pthread_mutex_t m_mutex)
    {
        this->m_mutex = m_mutex;
    }

    int getParent()
    {
        return _parent;
    }

    void setParent(int _parent)
    {
        this->_parent = _parent;
    }

    UI *getUi() const
    {
        return _ui;
    }

    void setUi(UI *_ui)
    {
        this->_ui = _ui;
    }


    int getSize() const
    {
        return _size;
    }

    void setSize(int _size)
    {
        this->_size = _size;
    }

    int getId() const
    {
        return _id;
    }

    void setId(int _id)
    {
        this->_id = _id;
    }

    string getWorkingDirectory() const
    {
        return _workingDirectory;
    }

    void setWorkingDirectory(string _workingDirectory)
    {
        this->_workingDirectory = _workingDirectory;
    }

    pthread_t getThread() const
    {
        return m_thread;
    }

    void setThread(pthread_t m_thread)
    {
        this->m_thread = m_thread;
    }

    pthread_cond_t* getQCond()
    {
        return &m_qCond;
    }

    void setQCond(pthread_cond_t m_qCond)
    {
        this->m_qCond = m_qCond;
    }

    vector<string>* getCommands()
    {
        return _commands;
    }

    void setCommands(vector<string>* _commands)
    {
        this->_commands = _commands;
    }


};

#endif /* MYPROCESS_H_ */
